import { http } from "@/utils/http";
import { baseUrlApi } from "@/api/utils";

export interface SysRole {
  id: number;
  slug: string;
  name: string;
  remark: string;
  sort: number;
  status: number;
}

export const getSysRoleList = (params?: object) => {
  return http.request<ApiResultPage<SysRole>>("get", baseUrlApi("sys_role"), {
    params
  });
};

export const getSysRoleInfo = (id: number) => {
  const url = `sys_role/${id}`;
  return http.request<ApiResult<SysRole>>("get", baseUrlApi(url), {});
};

export const createSysRole = (data: SysRole) => {
  return http.request<ApiResult<SysRole>>("post", baseUrlApi("sys_role"), {
    data
  });
};

export const updateSysRole = (data: SysRole) => {
  const url = `sys_role/${data.id}`;
  return http.request<ApiResult<SysRole>>("put", baseUrlApi(url), {
    data
  });
};

export const deleteSysRole = (id: number) => {
  const url = `sys_role/${id}`;
  return http.request<ApiResult<SysRole>>("delete", baseUrlApi(url));
};
